<?php
/**
 *    @version [ Masterton ]
 *    @package hwdVideoShare
 *    @copyright (C) 2007 - 2009 Highwood Design
 *    @license Creative Commons Attribution-Non-Commercial-No Derivative Works 3.0 Unported Licence
 *    @license http://creativecommons.org/licenses/by-nc-nd/3.0/
 */
defined( '_JEXEC' ) or die( 'Direct Access to this location is not allowed.' );

global $mainframe, $option, $smartyvs;

if (!file_exists(JPATH_SITE.DS.'administrator'.DS.'components'.DS.'com_hwdvideoshare'.DS)) {
	echo "<div style=\"border:1px solid #c30;color:#c30;margin: 0 0 5px 0;padding: 5px;font-weight: bold;text-align:left;text-align:center;\">The hwdVideoShare component is not installed, you can not use this module.</div>"; return;
}

$db =& JFactory::getDBO();
$my = & JFactory::getUser();
require_once(JPATH_SITE.DS.'administrator'.DS.'components'.DS.'com_hwdvideoshare'.DS.'helpers'.DS.'initialise.php');
hwdvsInitialise::coreRequire();
hwdvsInitialise::language();
hwdvsInitialise::template();
hwdvsInitialise::mysqlQuery();
hwdvsInitialise::definitions();

if (@_HWD_VS_PLUGIN_COMPS !== 214) {
	echo "<div style=\"border:1px solid #c30;color:#c30;margin: 0 0 5px 0;padding: 5px;font-weight: bold;text-align:left;text-align:center;\">This module is not compatible with your version of hwdVideoShare.</div>"; return;
}

$c = hwd_vs_Config::get_instance();
$video_id = JRequest::getInt( 'video_id', null );

/* Security Note: These values are auto-sanitized by mosGetParam() */
$hwdvids_params['mod_hwd_itemid'] 	= (int)$params->get( 'mod_hwd_itemid', '0');
$hwdvids_params['mod_searchcats'] 	= (int)$params->get( 'mod_searchcats', '0');
$hwdvids_params['search_text'] 	    = $params->get( 'search_text', null);
$hwdvids_params['mod_showbutton'] 	= (int)$params->get( 'mod_showbutton', '0');

if ($hwdvids_params['mod_hwd_itemid'] == 0) {
	$hwdvids_params['mod_hwd_itemid'] = hwd_vs_tools::generateValidItemid();
}

if ( empty($hwdvids_params['search_text']) || $hwdvids_params['search_text'] == '' || !isset($hwdvids_params['search_text']) ) {
	$input_text = "Search videos...";
} else {
	$input_text = $hwdvids_params['search_text'];
}

if ( $hwdvids_params['mod_searchcats'] == 1 ) {
	$smartyvs->assign("showcategories", 1);
	$category_select = hwd_vs_tools::categoryList(_HWDVIDS_INFO_CHOOSECAT, 0, _HWDVIDS_INFO_NOCATS, 1, "category_id", 0);
} else {
	$category_select = null;
}

if ( $hwdvids_params['mod_showbutton'] == 1 ) {
	$smartyvs->assign("showbutton", 1);
}

$smartyvs->assign("input_text", $input_text);
$smartyvs->assign("category_select", $category_select);
$smartyvs->assign("hwdvids_params", $hwdvids_params);

$smartyvs->display('mod_hwd_vs_search.tpl');
return;
?>